           var ezoom;
                    var ecenter;
                    var edirectionsDisplay = null;
                    var edflag = false;
                    var ewaypts = [];
                    function eberforerequest() {
                    var gmap = PF('ecliMap').getMap();
                            ecenter = gmap.getCenter();
                            ezoom = gmap.getZoom();
                    }
            function eafterrequest() {
            var gmap = PF('ecliMap').getMap();
                    setTimeout(function() {
                    gmap.setZoom(ezoom);
                            gmap.setCenter(ecenter);
                    }, 1);
            }
            function eberforerequesth() {
            console.log("eberforerequesth");
                    var gmap = PF('ecliMaph').getMap();
                    ecenter = gmap.getCenter();
                    ezoom = gmap.getZoom();
            }
            function eafterrequesth() {
            console.log("eafterrequesth");
                    var gmap = PF('ecliMaph').getMap();
                    setTimeout(function() {
                    gmap.setZoom(ezoom);
                            gmap.setCenter(ecenter);
                    }, 1);
            }
            function ehandlePointClick(event) {
            console.log("handlepointclick");
                    console.log(event.latLng.lat());
                    document.getElementById('eNlat').value = event.latLng.lat();
                    document.getElementById('eNlng').value = event.latLng.lng();
                    eberforerequest();
                    PF('edlg').show();
            }
            function emarkerAddComplete() {
            console.log("emarkerAddComplete");
                    var etitle = document.getElementById('etitle');
                    etitle.value = "";
                    eafterrequest();
                    PF('edlg').hide();
            }
            function ecancel() {
            document.getElementById('eNlat').value = "";
                    document.getElementById('eNlng').value = "";
                    var etitle = document.getElementById('etitle');
                    etitle.value = "";
                    PF('edlg').hide();
                    return false;
            }
            function ecalcRoute() {
            ewaypts = [];
                    if (edflag == false) {
            console.log("null")
            } else {
            console.log("not null")
                    edirectionsDisplay.setMap(null);
                    edirectionsDisplay = null;
                    edirectionsService = null;
            }
            var t1 = new google.maps.LatLng($('#et1lat').val(), $('#et1lng').val());
                    var t2 = new google.maps.LatLng($('#et2lat').val(), $('#et2lng').val());
                    console.log($('#et1lat').val());
                    console.log($('#et1lng').val());
                    console.log($('#et2lat').val());
                    console.log($('#et2lng').val());
                    var vals = $('#ewaypoint').val();
                    console.log("==========" + vals);
                    var epoints = vals.split(";");
                    console.log("==========" + epoints.length);
                    for (var i = 0; i < epoints.length - 1; i++){
            var latlng = epoints[i].split(",");
                    console.log("==========" + latlng);
                    ewaypts.push({
                    location: new google.maps.LatLng(latlng[0], latlng[1]),
                            stopover: true
                    })
            }
            edirectionsDisplay = new google.maps.DirectionsRenderer({'draggable': false});
                    edirectionsService = new google.maps.DirectionsService();
                    var emap = PF('ecliMap').getMap();
                    edirectionsDisplay.setMap(emap);
                    edirectionsDisplay.setPanel(document.getElementById("edirectionsPanel"));
                    var request = {
                    origin: t1,
                            destination: t2,
                            waypoints: ewaypts,
                            travelMode: google.maps.TravelMode.DRIVING
                    };
                    console.log(request);
                    edirectionsService.route(request, function(response, status) {
                    console.log(status);
                            if (status == google.maps.DirectionsStatus.OK) {
                    edirectionsDisplay.setDirections(response);
                    }
                    });
                    edflag = true;
            }
            function eclearall() {
            ewaypts = [];
                    if (edflag == false) {
            console.log("null")
            } else {
            console.log("not null")
                    edirectionsDisplay.setMap(null);
                    edirectionsDisplay = null;
                    edirectionsService = null;
                    edflag = false;
            }
            }
            function ecalcRouteh() {
            ewaypts = [];
                    if (edflag == false) {
            console.log("null")
            } else {
            console.log("not null")
                    edirectionsDisplay.setMap(null);
                    edirectionsDisplay = null;
                    edirectionsService = null;
                    edflag = false;
            }
            var t2 = new google.maps.LatLng($('#et1lat').val(), $('#et1lng').val());
                    var t1 = new google.maps.LatLng($('#et2lat').val(), $('#et2lng').val());
                    console.log($('#et1lat').val());
                    console.log($('#et1lng').val());
                    console.log($('#et2lat').val());
                    console.log($('#et2lng').val());
                    var vals = $('#ewaypointh').val();
                    console.log("==========" + vals);
                    var epoints = vals.split(";");
                    console.log("==========" + epoints.length);
                    for (var i = 0; i < epoints.length - 1; i++){
            var latlng = epoints[i].split(",");
                    console.log("==========" + latlng);
                    ewaypts.push({
                    location: new google.maps.LatLng(latlng[0], latlng[1]),
                            stopover: true
                    })
            }
            edirectionsDisplay = new google.maps.DirectionsRenderer({'draggable': false});
                    edirectionsService = new google.maps.DirectionsService();
                    var emap = PF('ecliMaph').getMap();
                    edirectionsDisplay.setMap(emap);
                    edirectionsDisplay.setPanel(document.getElementById("edirectionsPanel"));
                    var request = {
                    origin: t1,
                            destination: t2,
                            waypoints: ewaypts,
                            travelMode: google.maps.TravelMode.DRIVING
                    };
                    console.log(request);
                    edirectionsService.route(request, function(response, status) {
                    console.log(status);
                            if (status == google.maps.DirectionsStatus.OK) {
                    edirectionsDisplay.setDirections(response);
                    }
                    });
                    edflag = true;
            }
var currentMarker = null;
            var zoom;
            var center;
            var directionsDisplay = null;
            var dflag = false;
            var waypts = [];
            function berforerequest() {
                var gmap = PF('cliMap').getMap();
                center = gmap.getCenter();
                zoom = gmap.getZoom();

            }
            function afterrequest() {
                var gmap = PF('cliMap').getMap();
                setTimeout(function() {
                    gmap.setZoom(zoom);
                    gmap.setCenter(center);
                }, 1);
            }
            function berforerequesth() {
                console.log("berforerequesth");
                var gmap = PF('cliMaph').getMap();
                center = gmap.getCenter();
                zoom = gmap.getZoom();

            }
            function afterrequesth() {
                console.log("afterrequesth");
                var gmap = PF('cliMaph').getMap();
                setTimeout(function() {
                    gmap.setZoom(zoom);
                    gmap.setCenter(center);
                }, 1);
            }
            function handlePointClick(event) {
                console.log("handlepointclick");
                console.log(event.latLng.lat());
                document.getElementById('Nlat').value = event.latLng.lat();
                document.getElementById('Nlng').value = event.latLng.lng();
                berforerequest();
                PF('dlg').show();

            }

            function markerAddComplete() {
                console.log("markerAddComplete");
                var title = document.getElementById('title');
                title.value = "";
                afterrequest();
                PF('dlg').hide();


            }

            function cancel() {
                document.getElementById('Nlat').value = "";
                document.getElementById('Nlng').value = "";
                var title = document.getElementById('title');
                title.value = "";
                PF('dlg').hide();
                return false;
            }
            function calcRoute() {

                waypts = [];
                if (dflag == false) {
                    console.log("null")
                } else {
                    console.log("not null")
                    directionsDisplay.setMap(null);
                    directionsDisplay = null;
                    directionsService = null;
                }

                var t1 = new google.maps.LatLng($('#t1lat').val(), $('#t1lng').val());

                var t2 = new google.maps.LatLng($('#t2lat').val(), $('#t2lng').val());
                console.log($('#t1lat').val());
                console.log($('#t1lng').val());
                console.log($('#t2lat').val());
                console.log($('#t2lng').val());

                var vals = $('#waypoint').val();
                console.log("==========" + vals);
                var points = vals.split(";");
                console.log("==========" + points.length);
                for (var i = 0; i < points.length - 1; i++){
                    var latlng = points[i].split(",");
                    console.log("==========" + latlng);
                    waypts.push({
                        location: new google.maps.LatLng(latlng[0], latlng[1]),
                        stopover: true
                    })

                }


                directionsDisplay = new google.maps.DirectionsRenderer({'draggable': false});

                directionsService = new google.maps.DirectionsService();
                var map = PF('cliMap').getMap();

                directionsDisplay.setMap(map);

                directionsDisplay.setPanel(document.getElementById("directionsPanel"));
                var request = {
                    origin: t1,
                    destination: t2,
                    waypoints: waypts,
                    travelMode: google.maps.TravelMode.DRIVING
                };
                console.log(request);
                directionsService.route(request, function(response, status) {
                    console.log(status);
                    if (status == google.maps.DirectionsStatus.OK) {
                        directionsDisplay.setDirections(response);
                    }
                });
                dflag = true;
            }
            function clearall() {
                waypts = [];
                if (dflag == false) {
                    console.log("null")
                } else {
                    console.log("not null")
                    directionsDisplay.setMap(null);
                    directionsDisplay = null;
                    directionsService = null;
                    dflag = false;
                }
            }
            function calcRouteh() {

                waypts = [];
                if (dflag == false) {
                    console.log("null")
                } else {
                    console.log("not null")
                    directionsDisplay.setMap(null);
                    directionsDisplay = null;
                    directionsService = null;
                    dflag = false;
                }

                var t2 = new google.maps.LatLng($('#t1lat').val(), $('#t1lng').val());

                var t1 = new google.maps.LatLng($('#t2lat').val(), $('#t2lng').val());
                console.log($('#t1lat').val());
                console.log($('#t1lng').val());
                console.log($('#t2lat').val());
                console.log($('#t2lng').val());

                var vals = $('#waypointh').val();
                console.log("==========" + vals);
                var points = vals.split(";");
                console.log("==========" + points.length);
                for (var i = 0; i < points.length - 1; i++){
                    var latlng = points[i].split(",");
                    console.log("==========" + latlng);
                    waypts.push({
                        location: new google.maps.LatLng(latlng[0], latlng[1]),
                        stopover: true
                    })

                }


                directionsDisplay = new google.maps.DirectionsRenderer({'draggable': false});

                directionsService = new google.maps.DirectionsService();
                var map = PF('cliMaph').getMap();

                directionsDisplay.setMap(map);

                directionsDisplay.setPanel(document.getElementById("directionsPanel"));
                var request = {
                    origin: t1,
                    destination: t2,
                    waypoints: waypts,
                    travelMode: google.maps.TravelMode.DRIVING
                };
                console.log(request);
                directionsService.route(request, function(response, status) {
                    console.log(status);
                    if (status == google.maps.DirectionsStatus.OK) {
                        directionsDisplay.setDirections(response);
                    }
                });
                dflag = true;
            }


